using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Lzfy_Refund_Service.Models
{
    /// <summary>
    /// 线上退费记录
    /// </summary>
    [Table("PCA_PREPAY_REFUND_DETAIL", Schema = "PCA")]
    public class PrepayRefundDetail
    {
        /// <summary>
        /// 退费流水号
        /// </summary>
        [Key]
        [StringLength(32)]
        public string BalanceSn { get; set; } = string.Empty;

        /// <summary>
        /// 录入日期
        /// </summary>
        public DateTime? InputDate { get; set; } = DateTime.Now;

        /// <summary>
        /// 退费金额
        /// </summary>
        [Column(TypeName = "decimal(10,2)")]
        public decimal? RefundBalance { get; set; }

        /// <summary>
        /// 患者ID
        /// </summary>
        [StringLength(32)]
        public string? PatientId { get; set; }

        /// <summary>
        /// 患者姓名
        /// </summary>
        [StringLength(50)]
        public string? PatName { get; set; }

        /// <summary>
        /// 退款类型名称
        /// </summary>
        [StringLength(32)]
        public string? RefundTypeName { get; set; }

        /// <summary>
        /// 审核日期
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 结算日期
        /// </summary>
        public DateTime? AcctDate { get; set; }

        /// <summary>
        /// 审核人ID
        /// </summary>
        [StringLength(32)]
        public string? AuditUserId { get; set; }

        /// <summary>
        /// 审核人姓名
        /// </summary>
        [StringLength(32)]
        public string? AuditUserName { get; set; }

        /// <summary>
        /// 银行卡持有人
        /// </summary>
        [StringLength(50)]
        public string? BankCardHolder { get; set; }

        /// <summary>
        /// 账户ID
        /// </summary>
        [StringLength(50)]
        public string? AcctId { get; set; }

        /// <summary>
        /// 退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? RefundBankCity { get; set; }

        /// <summary>
        /// 公共代理退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? PublicAgentRefundBankCity { get; set; }
    }

    /// <summary>
    /// 线上退费记录查询请求
    /// </summary>
    public class PrepayRefundDetailQueryRequest
    {
        /// <summary>
        /// 患者ID
        /// </summary>
        public string? PatientId { get; set; }

        /// <summary>
        /// 患者姓名
        /// </summary>
        public string? PatName { get; set; }

        /// <summary>
        /// 退费流水号
        /// </summary>
        public string? BalanceSn { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime? EndDate { get; set; }

        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 页大小
        /// </summary>
        public int PageSize { get; set; } = 20;
    }

    /// <summary>
    /// 线上退费记录创建请求
    /// </summary>
    public class PrepayRefundDetailCreateRequest
    {
        /// <summary>
        /// 退费流水号
        /// </summary>
        [Required]
        [StringLength(32)]
        public string BalanceSn { get; set; } = string.Empty;

        /// <summary>
        /// 退费金额
        /// </summary>
        [Required]
        public decimal RefundBalance { get; set; }

        /// <summary>
        /// 患者ID
        /// </summary>
        [Required]
        [StringLength(32)]
        public string PatientId { get; set; } = string.Empty;

        /// <summary>
        /// 患者姓名
        /// </summary>
        [Required]
        [StringLength(50)]
        public string PatName { get; set; } = string.Empty;

        /// <summary>
        /// 退款类型名称
        /// </summary>
        [Required]
        [StringLength(32)]
        public string RefundTypeName { get; set; } = string.Empty;

        /// <summary>
        /// 审核日期
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 结算日期
        /// </summary>
        public DateTime? AcctDate { get; set; }

        /// <summary>
        /// 审核人ID
        /// </summary>
        [StringLength(32)]
        public string? AuditUserId { get; set; }

        /// <summary>
        /// 审核人姓名
        /// </summary>
        [StringLength(32)]
        public string? AuditUserName { get; set; }

        /// <summary>
        /// 银行卡持有人
        /// </summary>
        [StringLength(50)]
        public string? BankCardHolder { get; set; }

        /// <summary>
        /// 账户ID
        /// </summary>
        [StringLength(50)]
        public string? AcctId { get; set; }

        /// <summary>
        /// 退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? RefundBankCity { get; set; }

        /// <summary>
        /// 公共代理退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? PublicAgentRefundBankCity { get; set; }
    }

    /// <summary>
    /// 线上退费记录更新请求
    /// </summary>
    public class PrepayRefundDetailUpdateRequest
    {
        /// <summary>
        /// 退费流水号
        /// </summary>
        [Required]
        [StringLength(32)]
        public string BalanceSn { get; set; } = string.Empty;

        /// <summary>
        /// 退费金额
        /// </summary>
        public decimal? RefundBalance { get; set; }

        /// <summary>
        /// 退款类型名称
        /// </summary>
        [StringLength(32)]
        public string? RefundTypeName { get; set; }

        /// <summary>
        /// 银行卡持有人
        /// </summary>
        [StringLength(50)]
        public string? BankCardHolder { get; set; }

        /// <summary>
        /// 账户ID
        /// </summary>
        [StringLength(50)]
        public string? AcctId { get; set; }

        /// <summary>
        /// 退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? RefundBankCity { get; set; }

        /// <summary>
        /// 公共代理退费银行城市
        /// </summary>
        [StringLength(50)]
        public string? PublicAgentRefundBankCity { get; set; }
    }

    /// <summary>
    /// 线上退费记录审核请求
    /// </summary>
    public class PrepayRefundDetailAuditRequest
    {
        /// <summary>
        /// 退费流水号
        /// </summary>
        [Required]
        [StringLength(32)]
        public string BalanceSn { get; set; } = string.Empty;

        /// <summary>
        /// 审核人ID
        /// </summary>
        [Required]
        [StringLength(32)]
        public string AuditUserId { get; set; } = string.Empty;

        /// <summary>
        /// 审核人姓名
        /// </summary>
        [Required]
        [StringLength(32)]
        public string AuditUserName { get; set; } = string.Empty;
    }

    /// <summary>
    /// 线上退费记录响应
    /// </summary>
    public class PrepayRefundDetailResponse
    {
        /// <summary>
        /// 退费流水号
        /// </summary>
        public string BalanceSn { get; set; } = string.Empty;

        /// <summary>
        /// 录入日期
        /// </summary>
        public DateTime? InputDate { get; set; }

        /// <summary>
        /// 退费金额
        /// </summary>
        public decimal? RefundBalance { get; set; }

        /// <summary>
        /// 患者ID
        /// </summary>
        public string? PatientId { get; set; }

        /// <summary>
        /// 患者姓名
        /// </summary>
        public string? PatName { get; set; }

        /// <summary>
        /// 退款类型名称
        /// </summary>
        public string? RefundTypeName { get; set; }

        /// <summary>
        /// 审核日期
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 结算日期
        /// </summary>
        public DateTime? AcctDate { get; set; }

        /// <summary>
        /// 审核人ID
        /// </summary>
        public string? AuditUserId { get; set; }

        /// <summary>
        /// 审核人姓名
        /// </summary>
        public string? AuditUserName { get; set; }

        /// <summary>
        /// 银行卡持有人
        /// </summary>
        public string? BankCardHolder { get; set; }

        /// <summary>
        /// 账户ID
        /// </summary>
        public string? AcctId { get; set; }

        /// <summary>
        /// 退费银行城市
        /// </summary>
        public string? RefundBankCity { get; set; }

        /// <summary>
        /// 公共代理退费银行城市
        /// </summary>
        public string? PublicAgentRefundBankCity { get; set; }

        /// <summary>
        /// 退费状态（待审核、已审核、已结算）
        /// </summary>
        [NotMapped] // 非数据库字段，由Controller计算得出
        public string? Status { get; set; }
    }
}